package com.zhang.yygh.hosp.controller.admin;

import com.atguigu.yygh.model.hosp.Hospital;
import com.atguigu.yygh.vo.hosp.HospitalQueryVo;
import com.zhang.yygh.common.result.R;
import com.zhang.yygh.hosp.service.HospitalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

@Api(description = "医院接口")
@RestController
@RequestMapping("/admin/hosp/hospital")
//@CrossOrigin
public class HospitalController {

    @Autowired
    private HospitalService hospitalService;

    //修改医院列表状态
    @PutMapping("/updateStatus/{id}/{status}")
    public R updateStatus(@PathVariable String id,
                          @PathVariable Integer status){
        hospitalService.updateStatus(id,status);
        return R.ok();
    }

    @ApiOperation(value = "获取分页列表")
    @GetMapping("/{pageNum}/{pageSize}")
    public R getHospitalPage(@PathVariable Integer pageNum,
                             @PathVariable Integer pageSize,
                             HospitalQueryVo hospitalQueryVo){
        Page<Hospital> page=hospitalService.getHospitalPage(pageNum,pageSize,hospitalQueryVo);
        return R.ok().data("pages",page);
    }

    //根据医院id查询医院的详细信息
    @GetMapping("/detail/{id}")
    public R getHospitalDetailById(@PathVariable String id){
        Hospital hospital=hospitalService.getHospitalDetailByid(id);
        return R.ok().data("hospital",hospital);
    }


}
